import george_foreman.Tournament
import george_foreman.Player
import george_foreman.Match
import george_foreman.Entry
class BootStrap {

    def init = { servletContext ->
      //def old_sr=new Date('2010')
      //def sr=new Date('2011')
      //old_sr.save(failOnError:true)
      //sr.save(failOnError:true)
      def p1=new Player(name:"Good Player", classYear:2010,wins:100,losses:0,main:"Bowser")
      p1.save(failOnError:true)
      def p2=new Player(name:"Bad Player",classYear:2011,wins:0,losses:100,main:"metaknight")
      p2.save(failOnError:true)
      def t1=new Tournament(name:"George Foreman")
      t1.save(failOnError:true)
      def e1=new Entry(player:p1, tournament:t1)
      e1.save(failOnError:true)
      def e2=new Entry(player:p2, tournament:t1)
      e2.save(failOnError:true)
      def m1=new Match(section:"Round Robin",winner:p1,loser:p2,tournament:t1,stage:"Hanenbow")
      t1.addToEntrants(e1)
      t1.addToEntrants(e2)
      t1.addToMatches(m1)
      p1.addToTournaments(e1)
      p2.addToTournaments(e2)
      m1.save(failOnError:true)
    }
    def destroy = {
      

      
    }
}
